package org.refresh.prolog;

import java.util.HashMap;
import java.util.Map;

/******************************************************************************
 * Copyright (c) 2005, 2006 Jules White.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Jules White - initial API and implementation 
 ****************************************************************************/
public class BasicObjectManager implements ObjectManager {

	private Map<String, Object> objectsById_ = new HashMap<String, Object>();
	
	public String addObject(Object obj) {
		String id = getId(obj);
		objectsById_.put(id, obj);
		return id;
	}

	public String getId(Object obj) {
		return "id_"+obj.hashCode();
	}

	public Object getObject(String id) {
		return objectsById_.get(id);
	}

	public void removeObject(Object obj) {
		objectsById_.remove(getId(obj));
	}

}
